package com.pentalog.stock.dao.impl;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Juste to check to ensure that there is an transaction (propagated from service) 
 * @author tnguyenmanh
 *
 */
@Transactional(propagation = Propagation.MANDATORY, noRollbackFor = {Throwable.class})
public abstract class BaseDAO extends HibernateDaoSupport
{    
	/**
	 * Inject the session factory to the dao class because HibernateSupport must use it
	 * @param sessionFactory
	 */
	@Autowired
    public void injectSessionFactory(@Qualifier("sessionFactory") SessionFactory sessionFactory)
    {
        setSessionFactory(sessionFactory);
    }
	
}